#!/bin/bash
echo `date`
echo ' check_process.sh start'

cd /home/rancher/fengwei/api

function check(){
    process_name="parse_data"

    # 指定要查询和杀死的进程名称
    pid=`ps -ef | grep parse_data | grep -v grep | awk '{print $2}'`

    if [ -z "$pid" ]; then
        echo "No process found with name $process_name"
    else
        # 杀死进程
        echo "Killing process with PID $pid"
        kill $pid
    fi
    nohup java -jar parse_data-1.0-SNAPSHOT.jar --spring.profiles.active=prod > parse_prod.log 2>&1 &
}

check

echo 'end'
